<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>${sysName}</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="${resRoot}/layui/css/layui.css" media="all" />
  <link rel="stylesheet" href="${resRoot}/layui/admin/admin.css" media="all" />
	<link id="layuicss-layer" rel="stylesheet" href="${resRoot}/layui/css/modules/layer/default/layer.css" media="all">
	<script type="text/javascript" src="${resRoot}/ckeditor/ckeditor.js"></script>
	<script type="text/javascript" src="${resRoot}/ckfinder/ckfinder.js"></script>
</head>
<body>
<div class="layui-fluid">   
          <div class="layui-card">
          <div class="layui-form layui-card-header layuiadmin-card-header-auto"> 
 
<form class="layui-form" action="#" style="margin-top: 20px;margin-bottom:50px;" >
<input type="hidden" id="id" value="<#if tableInfoDTO??>${tableInfoDTO.id}<#else></#if>" >
<input type="hidden" id="dbId" value="${dbId}" >
  
  <div class="layui-form-item">
    <label class="layui-form-label">表名</label>
    <div class="layui-input-inline">
    <select name="tableName" id="tableName" >
    <#list tableList as table >
    <option <#if tableInfoDTO?? && tableInfoDTO.tableName?? && tableInfoDTO.tableName==table.name >selected="selected"</#if> value="${table.name!}" >${table.name}:${table.comment!}</option>
    </#list>
    </select>
    </div>
    <div class="layui-form-mid layui-word-aux">请输入表名</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">表id类型</label>
    <div class="layui-input-inline">
    
    <select name="tableIdType" id="tableIdType" >
    	<#list dictMap['db_id_type']?keys as key>
    	<option <#if tableInfoDTO?? && tableInfoDTO.tableIdType?? && tableInfoDTO.tableIdType==key >selected="selected"</#if> value="${key}" >${dictMap['db_id_type'][key]}</option>
    	</#list>
    	</select>
    </div>
    <div class="layui-form-mid layui-word-aux">请选择表id类型</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">超entity</label>
    <div class="layui-input-inline">
	      <input type="text" name="superEntity" id="superEntity" value="<#if tableInfoDTO?? && tableInfoDTO.superEntity?? >${tableInfoDTO.superEntity!}<#else>com.regex.web.entity.StrIdBaseEntity</#if>" lay-verify="title" autocomplete="off" placeholder="请输入超entity" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入超entity</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">超service</label>
    <div class="layui-input-inline">
	      <input type="text" name="superService" id="superService" value="<#if tableInfoDTO?? && tableInfoDTO.superService?? >${tableInfoDTO.superService!}<#else>com.regex.web.service.base.IBaseService</#if>" lay-verify="title" autocomplete="off" placeholder="请输入超service" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入超service</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">超impl</label>
    <div class="layui-input-inline">
	      <input type="text" name="superServiceImpl" id="superServiceImpl" value="<#if tableInfoDTO?? && tableInfoDTO.superServiceImpl?? >${tableInfoDTO.superServiceImpl!}<#else>com.regex.web.service.base.impl.BaseServiceImpl</#if>" lay-verify="title" autocomplete="off" placeholder="请输入超impl" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入超impl</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">包名</label>
    <div class="layui-input-inline">
	      <input type="text" name="packageName" id="packageName" value="<#if tableInfoDTO?? && tableInfoDTO.packageName?? >${tableInfoDTO.packageName!}</#if>" lay-verify="title" autocomplete="off" placeholder="请输入包名" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入包名</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">前缀</label>
    <div class="layui-input-inline">
	      <input type="text" name="prefix" id="prefix" value="<#if tableInfoDTO?? && tableInfoDTO.prefix?? >${tableInfoDTO.prefix! }</#if>" lay-verify="title" autocomplete="off" placeholder="请输入前缀" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入前缀</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">作者</label>
    <div class="layui-input-inline">
	      <input type="text" name="author" id="author" value="<#if tableInfoDTO?? && tableInfoDTO.author?? >${tableInfoDTO.author!}<#else>mhy</#if>" lay-verify="title" autocomplete="off" placeholder="请输入作者" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入作者</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">输出地址</label>
    <div class="layui-input-inline">
	      <input type="text" name="outPutDir" id="outPutDir" value="<#if tableInfoDTO?? && tableInfoDTO.outPutDir?? >${tableInfoDTO.outPutDir!}<#else>D://workspace/src/main/java</#if>" lay-verify="title" autocomplete="off" placeholder="请输入输出地址" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入输出地址</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">公共字段</label>
    <div class="layui-input-inline">
	      <input type="text" name="commonColumns" id="commonColumns" value="<#if tableInfoDTO?? && tableInfoDTO.commonColumns?? >${tableInfoDTO.commonColumns!}<#else>id,is_del,create_time,update_time</#if>" lay-verify="title" autocomplete="off" placeholder="请输入公共字段" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入公共字段</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">父包</label>
    <div class="layui-input-inline">
	      <input type="text" name="parentPackage" id="parentPackage" value="<#if tableInfoDTO?? && tableInfoDTO.parentPackage?? >${tableInfoDTO.parentPackage!}<#else>com.regex.web</#if>" lay-verify="title" autocomplete="off" placeholder="请输入父包" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入父包</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">id字段</label>
    <div class="layui-input-inline">
	      <input type="text" name="idColumn" id="idColumn" value="<#if tableInfoDTO?? && tableInfoDTO.idColumn?? >${tableInfoDTO.idColumn!}<#else></#if>" lay-verify="title" autocomplete="off" placeholder="请输入id字段" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入id字段</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">动态数据源名称</label>
    <div class="layui-input-inline">
	      <input type="text" name="dynamicDatasource" id="dynamicDatasource" value="<#if tableInfoDTO?? && tableInfoDTO.dynamicDatasource?? >${tableInfoDTO.dynamicDatasource!}<#else></#if>" lay-verify="title" autocomplete="off" placeholder="请输入动态数据源名称" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">不填则默认为主数据源</div>
  </div>
  
  <!-- <div class="layui-form-item">
    <label class="layui-form-label">实体包名称</label>
    <div class="layui-input-inline">
	      <input type="text" name="entityPackage" id="entityPackage" value="<#if tableInfoDTO?? && tableInfoDTO.entityPackage?? >${tableInfoDTO.entityPackage!}<#else>entity</#if>" lay-verify="title" autocomplete="off" placeholder="请输入实体包名称" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入实体包名称</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">service包名</label>
    <div class="layui-input-inline">
	      <input type="text" name="servicePackage" id="servicePackage" value="<#if tableInfoDTO?? && tableInfoDTO.servicePackage?? >${tableInfoDTO.servicePackage!}<#else>service</#if>" lay-verify="title" autocomplete="off" placeholder="请输入service包名" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入service包名</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">impl包名</label>
    <div class="layui-input-inline">
	      <input type="text" name="serviceImplPackage" id="serviceImplPackage" value="<#if tableInfoDTO?? && tableInfoDTO.serviceImplPackage?? >${tableInfoDTO.serviceImplPackage!}<#else>service</#if>" lay-verify="title" autocomplete="off" placeholder="请输入impl包名" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入impl包名</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">dao包名</label>
    <div class="layui-input-inline">
	      <input type="text" name="mapperPackage" id="mapperPackage" value="<#if tableInfoDTO?? && tableInfoDTO.mapperPackage?? >${tableInfoDTO.mapperPackage!}<#else>dao</#if>" lay-verify="title" autocomplete="off" placeholder="请输入dao包名" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入dao包名</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">xml包名</label>
    <div class="layui-input-inline">
	      <input type="text" name="xmlPackage" id="xmlPackage" value="<#if tableInfoDTO?? && tableInfoDTO.xmlPackage?? >${tableInfoDTO.xmlPackage!}<#else>dao</#if>" lay-verify="title" autocomplete="off" placeholder="请输入xml包名" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入xml包名</div>
  </div>
  
  <div class="layui-form-item">
    <label class="layui-form-label">controller包名</label>
    <div class="layui-input-inline">
	      <input type="text" name="controllerPackage" id="controllerPackage" value="<#if tableInfoDTO?? && tableInfoDTO.controllerPackage?? >${tableInfoDTO.controllerPackage!}<#else>controller</#if>" lay-verify="title" autocomplete="off" placeholder="请输入controller包名" class="layui-input">
    </div>
    <div class="layui-form-mid layui-word-aux">请输入controller包名</div>
  </div> -->
  

  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" id="submitBtn"  lay-submit=""  type="button">立即提交</button>
      <button type="button" class="layui-btn layui-btn-primary" onclick="backList();" >返回</button>
    </div>
  </div>
</form>
</div>
  </div>
  </div>
<script src="${resRoot}/layui/layui.js" charset="utf-8"></script>
<script src="${resRoot}/js/jquery.min.js?v=2.1.4"></script>
<script type="text/javascript" src="${resRoot}/js/ajaxfileupload.js"></script>
<script>
function backList() {
	layer.closeAll("iframe");
    //刷新父页面
    parent.location.reload();
}

function removeImg(id) {
	layer.confirm('您是确认删除/查看该图片吗？', {
		  btn: ['确认','查看'] //按钮
		}, function(){
			$("#" + id).attr("src", "");
			layer.msg('已删除！');
		}, function(){
			window.open($("#" + id).attr("src"));
		  //layer.msg('已取消！');
		});
}
layui.use(['form', 'layedit', 'laydate', 'upload'], function(){
  var form = layui.form
  ,layer = layui.layer
  ,layedit = layui.layedit
  ,laydate = layui.laydate;
  
  var upload = layui.upload;

  
  $("#submitBtn").click(function(){
		var dbId=$("#dbId").val();
	  var id = $("#id").val();
		var tableName=$("#tableName").val();
		var tableIdType=$("#tableIdType").val();
		var superEntity=$("#superEntity").val();
		var superService=$("#superService").val();
		var superServiceImpl=$("#superServiceImpl").val();
		var packageName=$("#packageName").val();
		var prefix=$("#prefix").val();
		var author=$("#author").val();
		var outPutDir=$("#outPutDir").val();
		var commonColumns=$("#commonColumns").val();
		var parentPackage=$("#parentPackage").val();
		var idColumn = $("#idColumn").val();
		var dynamicDatasource = $("#dynamicDatasource").val();
		/* var entityPackage=$("#entityPackage").val();
		var servicePackage=$("#servicePackage").val();
		var serviceImplPackage=$("#serviceImplPackage").val();
		var mapperPackage=$("#mapperPackage").val();
		var xmlPackage=$("#xmlPackage").val();
		var controllerPackage=$("#controllerPackage").val(); */
		var flag = true;
		if(dbId=="" || dbId ==null || dbId =="undefined") {
			layer.alert("请输入数据库id！");
		      flag = false;
		      return false;
		}
		if(tableName=="" || tableName ==null || tableName =="undefined") {
			layer.alert("请输入表名！");
		      flag = false;
		      return false;
		}
		if(tableIdType=="" || tableIdType ==null || tableIdType =="undefined") {
			layer.alert("请输入表id类型！");
		      flag = false;
		      return false;
		}
		/* if(superEntity=="" || superEntity ==null || superEntity =="undefined") {
			layer.alert("请输入超entity！");
		      flag = false;
		      return false;
		} */
		if(superService=="" || superService ==null || superService =="undefined") {
			layer.alert("请输入超service！");
		      flag = false;
		      return false;
		}
		if(superServiceImpl=="" || superServiceImpl ==null || superServiceImpl =="undefined") {
			layer.alert("请输入超impl！");
		      flag = false;
		      return false;
		}
		if(packageName=="" || packageName ==null || packageName =="undefined") {
			layer.alert("请输入包名！");
		      flag = false;
		      return false;
		}
		/* if(prefix=="" || prefix ==null || prefix =="undefined") {
			layer.alert("请输入前缀！");
		      flag = false;
		      return false;
		} */
		if(author=="" || author ==null || author =="undefined") {
			layer.alert("请输入作者！");
		      flag = false;
		      return false;
		}
		if(outPutDir=="" || outPutDir ==null || outPutDir =="undefined") {
			layer.alert("请输入输出地址！");
		      flag = false;
		      return false;
		}
		/* if(commonColumns=="" || commonColumns ==null || commonColumns =="undefined") {
			layer.alert("请输入公共字段！");
		      flag = false;
		      return false;
		} */
		if(parentPackage=="" || parentPackage ==null || parentPackage =="undefined") {
			layer.alert("请输入父包！");
		      flag = false;
		      return false;
		}
		/* if(entityPackage=="" || entityPackage ==null || entityPackage =="undefined") {
			layer.alert("请输入实体包名称！");
		      flag = false;
		      return false;
		}
		if(servicePackage=="" || servicePackage ==null || servicePackage =="undefined") {
			layer.alert("请输入service包名！");
		      flag = false;
		      return false;
		}
		if(serviceImplPackage=="" || serviceImplPackage ==null || serviceImplPackage =="undefined") {
			layer.alert("请输入impl包名！");
		      flag = false;
		      return false;
		}
		if(mapperPackage=="" || mapperPackage ==null || mapperPackage =="undefined") {
			layer.alert("请输入dao包名！");
		      flag = false;
		      return false;
		}
		if(xmlPackage=="" || xmlPackage ==null || xmlPackage =="undefined") {
			layer.alert("请输入xml包名！");
		      flag = false;
		      return false;
		}
		if(controllerPackage=="" || controllerPackage ==null || controllerPackage =="undefined") {
			layer.alert("请输入controller包名！");
		      flag = false;
		      return false;
		} */
		if(flag) {
			$.ajax({
				type : "post",
				url : "${base}/sys/tableInfo/save",
				data : {
					dbId : dbId,
					tableName : tableName,
					tableIdType : tableIdType,
					superEntity : superEntity,
					superService : superService,
					superServiceImpl : superServiceImpl,
					packageName : packageName,
					prefix : prefix,
					author : author,
					outPutDir : outPutDir,
					commonColumns : commonColumns,
					parentPackage : parentPackage,
					idColumn : idColumn,
					dynamicDatasource : dynamicDatasource,
					/* entityPackage : entityPackage,
					servicePackage : servicePackage,
					serviceImplPackage : serviceImplPackage,
					mapperPackage : mapperPackage,
					xmlPackage : xmlPackage,
					controllerPackage : controllerPackage, */
					id : id					
					},
				dataType : "json",
				async : false,
				success : function(data) {
					if(data.message == 2) {
							layer.msg('请完善数据！');   
						} else if(data.message == 1) {
							layer.msg('保存成功！', {
							  icon: 1,
							  time: 2000 //2秒关闭（如果不配置，默认是3秒）
							}, function(){
								backList();
							});   
						} else {
							layer.msg('系统繁忙！'); 
						}
				}
			}); 
		}
	});
  
  
});

layui.use('upload', function(){
	  
});  
</script>
</body>
</html>